package org.mark.sell.controller;

import org.mark.common.response.Result;
import org.mark.sell.entity.PromotionInfo;
import org.mark.sell.service.PromotionInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 促销信息
 */
@RestController
@RequestMapping("/promotion")
@CrossOrigin
public class PromotionInfoController {

    @Resource
    private PromotionInfoService promotionInfoService;

    @PostMapping("/page")
    public Result page(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) String name) {
        return promotionInfoService.page(pageNum, pageSize, name);
    }

    @PostMapping("/save")
    public Result save(@RequestBody PromotionInfo promotionInfo) {
        return promotionInfoService.save(promotionInfo);
    }

    @PostMapping("/update")
    public Result update(@RequestBody PromotionInfo promotionInfo) {
        return promotionInfoService.update(promotionInfo);
    }

    @PostMapping("/remove")
    public Result remove(@RequestBody PromotionInfo promotionInfo) {
        return promotionInfoService.remove(promotionInfo.getId());
    }
}